/* 基础样式 */
.chatIcon {
  position: fixed;
  bottom: 2em;
  right: 1.3em;
  z-index: 100;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: rgb(70, 70, 70);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  border: 1px solid rgb(90, 90, 90);
  cursor: pointer;
}

.chatContainer {
  position: fixed;
  z-index: 1024;
  right: 2em;
  bottom: 2em;
}

.chatIcon:hover {
  transform: scale(1.1);
}

.expanded {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60vw;
  max-width: 800px;
  height: 70vh;
  max-height: 600px;
  border-radius: 12px;
  background-color: rgb(50, 50, 50);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgb(70, 70, 70);
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1024;
  backdrop-filter: blur(2px);
}

/* 聊天窗口内部样式 */
.chatWindow {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.header {
  padding: 12px 16px;
  background-color: rgb(70, 70, 70);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgb(70, 70, 70);
}

.closeButton {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  transition: all 0.3s ease;
}

.closeButton:hover {
  color: #ffffffaa;
}

.chatContent {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 好友列表样式 */
.friendList {
  width: 35%;
  border-right: 1px solid rgb(70, 70, 70);
  overflow-y: auto;
  background-color: rgb(50, 50, 50);
}

.friendItem {
  display: flex;
  padding: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
  color: white;
}

.friendItem:hover {
  background-color: rgb(70, 70, 70);
}

.friendItem.active {
  background-color: rgb(90, 90, 90);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgb(70, 70, 70);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  position: relative;
  color: white;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.online::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: rgb(100, 150, 100);
  border: 1px solid rgb(50, 50, 50);
}

.avatar.offline::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: rgb(150, 100, 100);
  border: 2px solid rgb(50, 50, 50);
}

.friendInfo {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  overflow: hidden;
}

.friendName {
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 消息区域样式 */
.messageArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: rgb(40, 40, 40);
}

.messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.message {
  max-width: 70%;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  position: relative;
  word-wrap: break-word;
}

.messageContent {
  word-break: break-word;
}

.myMessage {
  align-self: flex-end;
  background-color: rgb(70, 70, 70);
  color: white;
  border-top-right-radius: 0;
}

.otherMessage {
  align-self: flex-start;
  background-color: rgb(70, 70, 70);
  color: white;
  border-top-left-radius: 0;
}

.messageTime {
  font-size: 10px;
  text-align: right;
  margin-top: 4px;
  opacity: 0.7;
  color: rgb(180, 180, 180);
}

.messageInput {
  display: flex;
  padding: 12px;
  border-top: 1px solid rgb(70, 70, 70);
  background-color: rgb(50, 50, 50);
}

.messageInput input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid rgb(70, 70, 70);
  border-radius: 4px;
  margin-right: 8px;
  outline: none;
  background-color: rgb(70, 70, 70);
  color: white;
}

.messageInput input::placeholder {
  color: rgb(180, 180, 180);
}

.messageInput button {
  padding: 8px 16px;
  background-color: rgb(70, 70, 70);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.messageInput button:hover {
  background-color: rgb(90, 90, 90);
}

/* 搜索区域样式 */
.searchSection {
  padding: 12px 16px;
  background-color: rgb(60, 60, 60);
  border-bottom: 1px solid rgb(70, 70, 70);
}

.searchInput {
  position: relative;
  display: flex;
  gap: 8px;
}

.searchInput input {
  flex: 1;
  padding: 8px 12px;
  background-color: rgb(70, 70, 70);
  border: 1px solid rgb(90, 90, 90);
  border-radius: 20px;
  color: white;
  outline: none;
}

.searchInput button {
  padding: 8px 16px;
  background-color: rgb(80, 80, 80);
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
}

.searchInput button:hover {
  background-color: #8b5cf6;
}

.searchInput button:disabled {
  background-color: rgb(60, 60, 60);
  color: rgb(120, 120, 120);
  cursor: not-allowed;
}

/* 搜索结果列表样式 */
.searchResults {
  position: absolute;
  top: 3em;
  z-index: 1024;
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  background-color: rgb(50, 50, 50);
  border-radius: 8px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.2);
}

.searchResultItem {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgb(70, 70, 70);
  transition: background-color 0.2s;
}

.searchResultItem:last-child {
  border-bottom: none;
}

.searchResultItem:hover {
  background-color: rgb(70, 70, 70);
}

.userInfo {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  font-size: 14px;
}

.addButton {
  padding: 6px 12px;
  background-color: rgb(80, 80, 80);
  color: #a78bfa;
  border: 1px solid #a78bfa;
  border-radius: 15px;
  cursor: pointer;
  font-size: 12px;
}

.addButton:hover {
  background-color: rgba(167, 139, 250, 0.2);
}

.friendAddedButton {
  padding: 6px 12px;
  background-color: rgb(60, 60, 60);
  color: rgb(120, 120, 120);
  border: 1px solid rgb(90, 90, 90);
  border-radius: 15px;
  font-size: 12px;
  cursor: not-allowed;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .expanded {
    width: 80vw;
    height: 80vh;
  }

  .friendList {
    width: 40%;
  }
}

@media (max-width: 480px) {
  .expanded {
    width: 90vw;
    height: 90vh;
  }

  .chatContent {
    flex-direction: column;
  }

  .friendList {
    width: 100%;
    height: 30%;
    border-right: none;
    border-bottom: 1px solid rgb(70, 70, 70);
  }
}
